package cn.spark.study.sql

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
import org.apache.spark.sql.SQLContext

object DataFrameOperation {
    def main(args:Array[String]):Unit = {
      val conf = new SparkConf()
        .setAppName("DataFrameOperation")
        
      val sc = new SparkContext(conf)
      val df = new SQLContext(sc).read.json("hdfs://spark1:9000/students.json")
      
      df.show();
      df.select("name").show()
      df.select(df.col("name"), df.col("age").plus(2)).show()
      df.filter(df.col("age").gt(18)).show()
      df.groupBy(df.col("name")).count().show()
    }
}